<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>excel格式转换</title>

</head>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<body>
<textarea id="content" style="width: 300px;height: 500px">请输入文本</textarea>
<h1>转换后的结果:</h1>
<textarea id="change_over" style="width: 600px;height: 200px"></textarea>
</body>
<script>
    $(document).ready(function(){
        $("#content").change(function(){
            var content = $('#content').val()
            content = content.replaceAll("\n",",")
            var char = content.charAt(content.length - 1)
            if(char == ','){
                content = content.substr(0, content.length - 1)
            }

            $('#change_over').html(content)
        });
    });
</script>
</html>